interface RequestConfig {
  BASE_URL: string;
  TIMEOUT: number;
  MAX_BODY_SIZE: number;
  DEFAULT_HEADERS: Record<string, string>;
  RETRY: {
    MAX_ATTEMPTS: number;
    DELAY: number;
    STATUS_CODES: number[];
  };
  CSRF: {
    COOKIE_NAME: string;
    HEADER_NAME: string;
    PATH: string;
    MAX_AGE: number;
  };
}

const config: RequestConfig = {
  BASE_URL: import.meta.env.VITE_API_BASE_URL || '/api',
  TIMEOUT: 10000,
  MAX_BODY_SIZE: 1024 * 1024, // 1MB
  DEFAULT_HEADERS: {
    'Content-Type': 'application/json',
    Accept: 'application/json',
    'X-Requested-With': 'XMLHttpRequest',
  },
  RETRY: {
    MAX_ATTEMPTS: 3,
    DELAY: 300,
    STATUS_CODES: [502, 503, 504],
  },
  CSRF: {
    COOKIE_NAME: 'XSRF-TOKEN', // HttpOnly Cookie名称
    HEADER_NAME: 'X-XSRF-TOKEN', // 请求头名称
    PATH: '/', // Cookie路径
    MAX_AGE: 24 * 60 * 60, // 有效期（秒）：86400
  },
};

export default config;
